#!/usr/bin/env python3
"""
Example script demonstrating how to use the DeepSeek client
"""

import os
import sys
from pathlib import Path

# Add package to path for development
sys.path.insert(0, str(Path(__file__).parent.parent))

from qwen3_client import DeepSeekClient, DeepSeekConfig, quick_setup_deepseek

def main():
    """Example usage of DeepSeek client"""
    
    print("DeepSeek Client Example")
    print("=" * 40)
    
    try:
        # Method 1: Quick setup using convenience function
        print("\n1. Quick setup from .env configuration:")
        client, logger = quick_setup_deepseek("INFO")
        
        # Test simple question
        question = "What is artificial intelligence?"
        print(f"\nAsking: {question}")
        response = client.ask(question)
        print(f"Response: {response[:200]}...")
        
        # Method 2: Manual configuration
        print("\n\n2. Manual configuration:")
        config = DeepSeekConfig(
            api_key=os.getenv('DEEPSEEK_API_KEY', ''),
            model_name='deepseek-chat',
            max_tokens=1000,
            temperature=0.7,
            skip_validation=True  # For demo purposes
        )
        
        manual_client = DeepSeekClient(config, logger)
        
        # Test Chinese technical response
        chinese_question = "请解释深度学习的基本原理"
        print(f"\nChinese technical question: {chinese_question}")
        chinese_response = manual_client.ask_chinese_technical(
            chinese_question, 
            domain="人工智能"
        )
        print(f"Chinese response: {chinese_response[:200]}...")
        
        # Method 3: Batch processing
        print("\n\n3. Batch processing:")
        questions = [
            "What is machine learning?",
            "Explain neural networks",
            "What are transformers in AI?"
        ]
        
        batch_results = client.batch_ask(questions)
        for i, (q, a) in enumerate(batch_results.items(), 1):
            print(f"\nQ{i}: {q}")
            print(f"A{i}: {a[:100]}...")
        
        print("\n✅ All examples completed successfully!")
        
    except Exception as e:
        print(f"❌ Error: {e}")
        
        # If API key is missing, show helpful message
        if "DEEPSEEK_API_KEY" in str(e):
            print("\nTo use the DeepSeek client, you need to:")
            print("1. Set DEEPSEEK_API_KEY environment variable")
            print("2. Or add it to your .env file")
            print("3. Or set QWEN_SKIP_API_VALIDATION=true for demo mode")


if __name__ == "__main__":
    main()